package com.tedu.api.io;

import org.junit.Test;

import java.io.*;

public class HomeWork1 {
    @Test
    public void testHomeWork1() {
      // ①错误
        try{
        File file = new File(".");
        System.out.println("查看路径：" + file.getCanonicalPath());
    } catch (IOException e) {
        e.printStackTrace();
    }
        //②错误
        try {
            FileOutputStream  fo = new FileOutputStream("fos.txt");
            fo.write("张煜炫".getBytes());
            fo.close();
        }catch (FileNotFoundException e){
            e.printStackTrace();
        }catch (IOException e) {
            e.printStackTrace();
        }
        //③错误
        try {
            FileOutputStream fos = null;
            fos = new FileOutputStream("bos.txt");
            BufferedOutputStream bos = new BufferedOutputStream(fos);
            String str = "张煜炫招人稀罕";
            bos.write(str.getBytes());
            bos.close();
            fos.close();
        }catch (FileNotFoundException e)
        {
            e.printStackTrace();
        }catch (IOException e) {
            e.printStackTrace();
        }
        //④错误
        try {
        FileOutputStream fis=new FileOutputStream("");
        BufferedOutputStream bos=new BufferedOutputStream(fis,18);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
        //⑤错误
        try {
        String s = "o";
        s.charAt(0);
        Integer.parseInt(s);
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
        finally {
        System.out.println();
    }
}
}
